//
//  AddSignsViewController.m
//  Nurse
//
//  Created by 张攀 on 13-12-25.
//  Copyright (c) 2013年 RainSets. All rights reserved.
//

#import "AddSignsViewController.h"
#import "PatientInfoView.h"

#import "PatientService.h"
#import "AddSignsViewPickerCell.h"
#import "BlocksKit.h"
#import "BlocksKit+UIKit.h"
#import "TPKeyboardAvoidingScrollView.h"
#import "OrdersService.h"
#import "OperatorService.h"
#import "PatientService.h"
#import "NurseService.h"
#import "BodyHeatController.h"


@interface AddSignsViewController (){
    BOOL _isShowingDataPicker;
    bool _isDatetime;
    
    UIDatePicker *_datePicker;
    UIDatePicker *_timePicker;
    UIPickerView *_pickerview;
    UIToolbar *_toolbar;
    UITextField *_textfield;
    NSArray *pickerData;
   
}
@property (strong, nonatomic) IBOutlet UIView *Uihx;//呼吸
@property (strong, nonatomic) IBOutlet UIView *Uitw;//体温
@property (strong, nonatomic) IBOutlet UIView *Uizy;//中医
@property (strong, nonatomic) IBOutlet UIView *Uixl;//心率
@property (strong, nonatomic) IBOutlet UIView *Uimb;//脉搏
@property (strong, nonatomic) IBOutlet UIView *Uixy;//血压
@property (strong, nonatomic) IBOutlet UIView *Uinzl;//尿总量
@property (strong, nonatomic) IBOutlet UIView *Uidb;//大便
@property (strong, nonatomic) IBOutlet UIView *Uiqtc;
@property (strong, nonatomic) IBOutlet UIView *Uisg;
@property (strong, nonatomic) IBOutlet UIView *Uigm;

@property(nonatomic,weak)IBOutlet TPKeyboardAvoidingScrollView *tpScroll;
@property(nonatomic,weak)IBOutlet UILabel *lblDate;//日期
@property (strong, nonatomic) IBOutlet UILabel *lblsstts;//第二手术天数
@property (strong, nonatomic) IBOutlet UIButton *Btrq;
@property (strong, nonatomic) IBOutlet UIButton *Btjq;
@property (strong, nonatomic) IBOutlet UIButton *Btsj;
@property (strong, nonatomic) IBOutlet UIImageView *Uijq;
@property (strong, nonatomic) IBOutlet UIImageView *Imgrq;
@property (strong, nonatomic) IBOutlet UIImageView *Imgsj;
@property (strong, nonatomic) IBOutlet UIImageView *Imgdate;
@property (strong, nonatomic) IBOutlet UIImageView *Imgtime;

@property(nonatomic,weak)IBOutlet UILabel *lblTime;//时间
@property (strong, nonatomic) IBOutlet UILabel *lbljq;//节气
@property (strong, nonatomic) IBOutlet UILabel *lblmx;//脉象
@property (strong, nonatomic) IBOutlet UILabel *lblss;//舌色
@property (strong, nonatomic) IBOutlet UILabel *lblts;//苔色
@property (strong, nonatomic) IBOutlet UILabel *lblwd;//温度类型
@property (strong, nonatomic) IBOutlet UILabel *lblssts;//手术天数
@property (strong, nonatomic) IBOutlet UITextField *Texttw;//t体温
@property (strong, nonatomic) IBOutlet UITextField *Textmb;//t脉搏
@property (strong, nonatomic) IBOutlet UITextField *Textxl;//t心率
@property (strong, nonatomic) IBOutlet UITextField *Texthx;//t呼吸
@property (strong, nonatomic) IBOutlet UITextField *Texthxd;//t血压低
@property (strong, nonatomic) IBOutlet UITextField *Texthxg;//t血压高
@property (strong, nonatomic) IBOutlet UITextField *Textnzl;//t尿总量
@property (strong, nonatomic) IBOutlet UITextField *Textdb;//t大便
@property (strong, nonatomic) IBOutlet UITextField *Textqtc;//t其他出
@property (strong, nonatomic) IBOutlet UITextField *Textsg;//t身高
@property (strong, nonatomic) IBOutlet UITextField *Texttz;//t体重
@property (strong, nonatomic) IBOutlet UIButton *Hxbutton;
@property (strong, nonatomic) IBOutlet UIButton *Mbbutton;
@property (strong, nonatomic) IBOutlet UIButton *Xlbutton;
@property (strong, nonatomic) IBOutlet UIButton *Grbutton;



//@property(nonatomic,strong)NSArray* Jq;

@end




@implementation AddSignsViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}



- (void)viewDidLoad
{
    
    
    // Do any additional setup after loading the view from its nib.
    
    self.title  = @"体征";
    
    
    NSArray * ibs2 = [[NSBundle mainBundle] loadNibNamed:@"AddSignsViewController" owner:self options:nil];
    UIView *contentView = [ibs2 lastObject];
    [self.tpScroll addSubview:contentView];
    
    [self.tpScroll contentSizeToFit];
    
    [super viewDidLoad];
    
    
    
    [self setleftBarButtonItem:@""orImaged:@"head-icon_04.png" Event:@selector(leftBar_clicked:)];
    
    // [self setrightBarButtonItem:@"完成"orImaged:nil Event:@selector(rightBar_clicked:)];
    
    UIButton *btnEdit = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnEdit setFrame:CGRectMake(0.f, 0.f, 40.f, 30.f)];
    //    [btnEdit setImage:[UIImage imageNamed:@".png"] forState:UIControlStateNormal];
    [btnEdit setTitle:@"完成" forState:UIControlStateNormal];
    [btnEdit setTitleColor:[UIColor colorWithRed:19.f / 255.f green:127 / 255.f blue:110.f / 255.f alpha:1.f] forState:UIControlStateNormal];
    [btnEdit setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [btnEdit addTarget:self action:@selector(rightBar_clicked:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *leftBarItem = [[UIBarButtonItem alloc] initWithCustomView:btnEdit];
    [self.navigationItem setRightBarButtonItem:leftBarItem];
    
    
    
    
    // NSArray *ibs = [[NSBundle mainBundle] loadNibNamed:@"PatientInfoView" owner:nil options:nil];
    // TestView *test = [ibs objectAtIndex:0];
    //PatientInfoView *pInfoView = (PatientInfoView *)[ibs objectAtIndex:0];
    
    
    NSDictionary* patient = [[PatientService sharedInstance]currentPatient];
    self.pInfoView.txtPatientName.text = [patient valueForKey:@"姓名"];
    self.pInfoView.txtPatientID.text = [NSString stringWithFormat:@"住院号:%@",[patient valueForKey:@"住院号"]];
    self.pInfoView.txtBedNo.text = [NSString stringWithFormat:@"床位号:%@",[patient valueForKey:@"床位号"]];
    NSString*xb= [patient valueForKey:@"性别"];
    if ([xb isEqualToString:@"女"]) {
        self.pInfoView.imgxb.image=[UIImage imageNamed:@"gender-female2.png"];
        
    }
    else{
        self.pInfoView.imgxb.image=[UIImage imageNamed:@"gender-male2.png"];
    }
    
    
    NSDate *  senddate=[NSDate date];
    
    NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];
    
    [dateformatter setDateFormat:@"YYYYMMdd"];
    
    NSString *  locationString=[dateformatter stringFromDate:senddate];
    
    [self setJq:locationString];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    self.lblDate.text = [NSString stringWithFormat:@"%@",[formatter stringFromDate:senddate]];
    self.lblDate.textColor=[UIColor darkTextColor];
    
//    
//    AppDelegate  *appDelegate = App;
//    // appDelegate.isScan=NO;
//    _Twdlx=appDelegate.Twdtype;
     // self.Twdlx=@"西医";
    
      
    if([self.Twdlx isEqualToString:@"西医"])
    {
        self.Uizy.hidden=YES;
        [self Arrangementxy:@"0"];
        self.Btjq.hidden=YES;
        self.Uijq.hidden=YES;
        CGRect btrqFrame = CGRectMake(7.0, 13.0, 150.0, 33.0);
        self.Btrq.frame =btrqFrame;
        self.Imgrq.frame=btrqFrame;
        self.Imgdate.hidden=NO;
        
        CGRect lblrqFrame = CGRectMake(40.0, 8.0, 83, 16);
        self.lblDate.frame=lblrqFrame;
        
        CGRect btsjFrame = CGRectMake(165.0, 13.0, 150.0, 33.0);
        self.Btsj.frame =btsjFrame;
        self.Imgsj.frame=btsjFrame;
        self.Imgtime.hidden=NO;
        CGRect lblsjFrame = CGRectMake(60.0, 8.0, 83, 16);
        self.lblTime.frame=lblsjFrame;
    
    }
    else
    {
        self.Uizy.hidden=NO;
        [self Arrangement:@"0"];
        self.Btjq.hidden=NO;
        self.Uijq.hidden=NO;
//        CGRect btrqFrame = CGRectMake(7.0, 10.0, 98.0, 33.0);
//        self.Btrq.frame =btrqFrame;
//        self.Imgrq.frame=btrqFrame;
//        
//        CGRect btsjFrame = CGRectMake(111.0, 10.0, 98.0, 33.0);
//        self.Btsj.frame =btsjFrame;
//        self.Imgsj.frame=btsjFrame;
    
    }
    
    
    
    
}


-(void)setOffset
{

    CGPoint newScrollViewContentOffset = self.tpScroll.contentOffset;
    float yd;
    yd=504+244-newScrollViewContentOffset.y-504;
    newScrollViewContentOffset.y =newScrollViewContentOffset.y+yd;
    //最后设置scollView's contentOffset
    self.tpScroll.contentOffset = newScrollViewContentOffset;
    [self.tpScroll setContentOffset:newScrollViewContentOffset animated:YES];

}


-(void)setJq:(NSString *)rq
{
    //[[OrdersService alloc] init];
    [[OrdersService sharedInstance]queryOrdersForJQ:rq withSuccessHandler:^(id result) {
        if ([result isKindOfClass:[NSArray class]]) {
            //[this.table reloadData];
            id record = [result objectAtIndex:0];
            self.lbljq.text=[record valueForKey:@"节气名称"];
        }
    } andFailHandler:^(NSError *error, NSString *title) {
        [[DataEngine sharedInstance]showMessage:[error description] withTitle:@"访问节气数据错误"];
    }];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)leftBar_clicked:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
    
}

-(IBAction)xl_clicked:(id)sender
{
    if (self.Xlbutton.selected)
    {
        self.Xlbutton.selected=NO;
    }
    else
    {
        self.Xlbutton.selected=YES;
    }
    
    
}
- (IBAction)gr_clicked:(id)sender {
    
    if (self.Grbutton.selected)
    {
        self.Grbutton.selected=NO;
    }
    else
    {
        self.Grbutton.selected=YES;
    }
}


-(IBAction)hx_clicked:(id)sender
{
    if (self.Hxbutton.selected)
    {
        self.Hxbutton.selected=NO;
    }
    else
    {
        self.Hxbutton.selected=YES;
    }
    
    
}
- (IBAction)Mb_click:(id)sender {
    if (self.Mbbutton.selected)
    {
        self.Mbbutton.selected=NO;
    }
    else
    {
        self.Mbbutton.selected=YES;
    }
    
}

-(void)rightBar_clicked:(id)sender
{
    
    //    @property(nonatomic,weak)IBOutlet UILabel *lblDate;//日期
    NSString* date = self.lblDate.text;
    //    @property (strong, nonatomic) IBOutlet UILabel *lblsstts;//第二手术天数
    NSString* lsstts = self.lblsstts.text;
    //    @property(nonatomic,weak)IBOutlet UILabel *lblTime;//时间
    NSString* time = self.lblTime.text;
    //    @property (strong, nonatomic) IBOutlet UILabel *lbljq;//节气
    NSString* jq = self.lbljq.text;
    //    @property (strong, nonatomic) IBOutlet UILabel *lblmx;//脉象
    NSString* mx = self.lblmx.text;
    //    @property (strong, nonatomic) IBOutlet UILabel *lblss;//舌色
    NSString* ss = self.lblss.text;
    //    @property (strong, nonatomic) IBOutlet UILabel *lblts;//苔色
    NSString* ts = self.lblts.text;
    //    @property (strong, nonatomic) IBOutlet UILabel *lblwd;//温度类型
    NSString* wd = self.lblwd.text;
    //    @property (strong, nonatomic) IBOutlet UILabel *lblssts;//手术天数
    NSString* ssts = self.lblssts.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Texttw;//t体温
    NSString* tw = self.Texttw.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Textmb;//t脉搏
    NSString* mb = self.Textmb.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Textxl;//t心率
    NSString* xl = self.Textxl.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Texthx;//t呼吸
    NSString* hx = self.Texthx.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Texthxd;//t血压低
    NSString* hxd = self.Texthxd.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Texthxg;//t血压高
    NSString* hxg = self.Texthxg.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Textnzl;//t尿总量
    NSString* nzl = self.Textnzl.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Textdb;//t大便
    NSString* db = self.Textdb.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Textqtc;//t其他出
    NSString* qtc = self.Textqtc.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Textsg;//t身高
    NSString* sg = self.Textsg.text;
    //    @property (strong, nonatomic) IBOutlet UITextField *Texttz;//t体重
    NSString* tz = self.Texttz.text;
    
    NSString* gmqk = self.textGMQK.text;
    
    //    @property (strong, nonatomic) IBOutlet UIButton *Hxbutton;
    NSNumber* bhx = [NSNumber numberWithBool:self.Hxbutton.selected];
    
    //    @property (strong, nonatomic) IBOutlet UIButton *Mbbutton;
    NSNumber* bmb = [NSNumber numberWithBool:self.Mbbutton.selected];
    
    //    @property (strong, nonatomic) IBOutlet UIButton *Xlbutton;
    NSNumber* bxl = [NSNumber numberWithBool:self.Xlbutton.selected];
    
    //    @property (strong, nonatomic) IBOutlet UIButton *Grbutton;
    NSNumber* bgr = [NSNumber numberWithBool:self.Grbutton.selected];
    
    NSMutableArray* array = [NSMutableArray array];
    
    //    select @日期, @时间, @记录工号, getdate(), @住院号, @节气, @脉象, @舌色, @苔色, @体温, @高热降温, @温度类型, @第一手术天数, @第二手术天数, @脉搏, @脉搏短促, @心率, @起搏器, @呼吸, @呼吸机, @血压低, @血压高, @尿总量, @大便, @其他出量, @身高, @体重, @过敏情况, @总入量
    NSDictionary* dict = [OperatorService sharedInstance].currentOperator ;
    NSDictionary* p = [PatientService sharedInstance].currentPatient;
    [array addObject:date];
    [array addObject:time];
    [array addObject:[dict valueForKey:@"工号"]];
    [array addObject:[p valueForKey:@"住院号"]];
    [array addObject:jq];
    [array addObject:mx];
    [array addObject:ss];
    [array addObject:ts];
    [array addObject:tw];
    [array addObject:[bgr stringValue]];
    [array addObject:wd];
    [array addObject:ssts];
    [array addObject:lsstts];
    [array addObject:mb];
    [array addObject:[bmb stringValue]];
    [array addObject:xl];
    [array addObject:[bxl stringValue]];
    [array addObject:hx];
     [array addObject:[bhx stringValue]];
    [array addObject:hxd];
    [array addObject:hxg];
    [array addObject:nzl];
    [array addObject:db];
    [array addObject:qtc];
    [array addObject:sg];
    [array addObject:tz];
    [array addObject:gmqk];
    
    NSString* postData = [array componentsJoinedByString:@";"];
    
    NSLog(@"postData:%@",postData);
    
    [[NurseService sharedInstance]postSignsWithData:postData withSuccessHandler:^(id result) {
        [[DataEngine sharedInstance]showMessage:@"插入体温记录成功" withTitle:@"插入成功"];
        [self.navigationController popViewControllerAnimated:YES];
    } andFailHandler:^(NSError *error, NSString *title) {
        [[DataEngine sharedInstance]showMessage:[error description] withTitle:@"插入失败"];
    }];
    
    
    
    
}

-(void)Arrangementxy:(NSString *)strBz
{
    // self.Uizy.frame.origin.y=244+84f;
    // self.Uizy.frame.origin.y==244+84;
    if([strBz isEqual:@"1"])
    {
        //[self.Uizy setTop:(50+244)];
        [self.Uitw setTop:(237-187+244)];
        [self.Uimb setTop:(424-187+244)];
        [self.Uixl setTop:(481-187+244)];
        [self.Uihx setTop:(538-187+244)];
        [self.Uixy setTop:(595-187+244)];
        [self.Uidb setTop:(709-187+244)];
        [self.Uinzl setTop:(766-187+244)];
        [self.Uiqtc setTop:(824-187+244)];
        [self.Uisg setTop:(880-187+244)];
        [self.Uigm setTop:(937-187+244)];
        //[self.Uinzl setTop:(692+130)];
        
    }
    if([strBz isEqual:@"0"])
    {
        //[self.Uizy setTop:(50)];
        [self.Uitw setTop:(237-187)];
        [self.Uimb setTop:(424-187)];
        [self.Uixl setTop:(481-187)];
        [self.Uihx setTop:(538-187)];
        [self.Uixy setTop:(595-187)];
        [self.Uidb setTop:(709-187)];
        [self.Uinzl setTop:(766-187)];
        [self.Uiqtc setTop:(824-187)];
        [self.Uisg setTop:(880-187)];
        [self.Uigm setTop:(937-187)];

        //[self.Uinzl setTop:(692)];
        
    }
    if([strBz isEqual:@"2"])
    {
        [self.Uitw setTop:(237-187+244)];
        [self.Uimb setTop:(424-187+244)];
        [self.Uixl setTop:(481-187+244)];
        [self.Uihx setTop:(538-187+244)];
        [self.Uixy setTop:(595-187+244)];
        [self.Uidb setTop:(709-187+244)];
        [self.Uinzl setTop:(766-187+244)];
        [self.Uiqtc setTop:(824-187+244)];
        [self.Uisg setTop:(880-187+244)];
        [self.Uigm setTop:(937-187+244)];

        
        //[self.Uinzl setTop:(692+105)];
    }
    
    if([strBz isEqual:@"3"])
    {
        [self.Uimb setTop:(424-187+244)];
        [self.Uixl setTop:(481-187+244)];
        [self.Uihx setTop:(538-187+244)];
        [self.Uixy setTop:(595-187+244)];
        [self.Uidb setTop:(709-187+244)];
        [self.Uinzl setTop:(766-187+244)];
        [self.Uiqtc setTop:(824-187+244)];
        [self.Uisg setTop:(880-187+244)];
        [self.Uigm setTop:(937-187+244)];

    }
    
    
}



-(void)Arrangement:(NSString *)strBz
{
    // self.Uizy.frame.origin.y=244+84f;
    // self.Uizy.frame.origin.y==244+84;
    if([strBz isEqual:@"1"])
    {
        [self.Uizy setTop:(50+244)];
        [self.Uitw setTop:(237+244)];
        [self.Uimb setTop:(424+244)];
        [self.Uixl setTop:(481+244)];
        [self.Uihx setTop:(538+244)];
        [self.Uixy setTop:(595+244)];
        [self.Uidb setTop:(709+244)];
        [self.Uinzl setTop:(766+244)];
        [self.Uiqtc setTop:(824+244)];
        [self.Uisg setTop:(880+244)];
        [self.Uigm setTop:(937+244)];

        //[self.Uinzl setTop:(692+130)];
        
    }
    if([strBz isEqual:@"0"])
    {
        [self.Uizy setTop:(50)];
        [self.Uitw setTop:(237)];
        [self.Uimb setTop:(424)];
        [self.Uixl setTop:(481)];
        [self.Uihx setTop:(538)];
        [self.Uixy setTop:(595)];
        [self.Uidb setTop:(709)];
        [self.Uinzl setTop:(766)];
        [self.Uiqtc setTop:(824)];
        [self.Uisg setTop:(880)];
        [self.Uigm setTop:(937)];
        //[self.Uinzl setTop:(692)];
        
    }
    if([strBz isEqual:@"2"])
    {
        [self.Uitw setTop:(237+244)];
        [self.Uimb setTop:(424+244)];
        [self.Uixl setTop:(481+244)];
        [self.Uihx setTop:(538+244)];
        [self.Uixy setTop:(595+244)];
        [self.Uidb setTop:(709+244)];
        [self.Uinzl setTop:(766+244)];
        [self.Uiqtc setTop:(824+244)];
        [self.Uisg setTop:(880+244)];
        [self.Uigm setTop:(937+244)];

        //[self.Uinzl setTop:(692+105)];
        }
    
    if([strBz isEqual:@"3"])
    {
        [self.Uimb setTop:(424+244)];
        [self.Uixl setTop:(481+244)];
        [self.Uihx setTop:(538+244)];
        [self.Uixy setTop:(595+244)];
        [self.Uidb setTop:(709+244)];
        [self.Uinzl setTop:(766+244)];
        [self.Uiqtc setTop:(824+244)];
        [self.Uisg setTop:(880+244)];
        [self.Uigm setTop:(937+244)];
    }
    
    
}
-(void)Hidden{
    
    if (_datePicker)
    {
        [self Arrangement:@"0"];
        [_datePicker removeFromSuperview];
        [_toolbar removeFromSuperview];
        _datePicker = nil;
        
    }
    
    if (_timePicker)
    {
        [self Arrangement:@"0"];
        [_timePicker removeFromSuperview];
        [_toolbar removeFromSuperview];
        _timePicker = nil;
        
    }
    [self.Texttw resignFirstResponder];
    [self.Texttz resignFirstResponder];
    [self.Textmb resignFirstResponder];
    [self.Textnzl resignFirstResponder];
    [self.Textqtc resignFirstResponder];
    [self.Textsg resignFirstResponder];
    [self.Textxl resignFirstResponder];
    [self.Textdb resignFirstResponder];
    [self.Texthx resignFirstResponder];
    [self.Texthxd resignFirstResponder];
    [self.Texthxg resignFirstResponder];
    
}

- (IBAction)Twclick:(id)sender {

        BodyHeatController *vc = nil;
        vc = [[BodyHeatController alloc] initWithNibName:@"BodyHeatController" bundle:nil];
        vc.type=@"体温";
        [self.navigationController pushViewController:vc animated:YES];
    
      //vc.title=@"体温";
        

}
- (IBAction)maiboclick:(id)sender {
    BodyHeatController *vc = nil;
    vc = [[BodyHeatController alloc] initWithNibName:@"BodyHeatController" bundle:nil];
    vc.type=@"脉搏";
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)xinlvclick:(id)sender {
    BodyHeatController *vc = nil;
    vc = [[BodyHeatController alloc] initWithNibName:@"BodyHeatController" bundle:nil];
    vc.type=@"心率";
    [self.navigationController pushViewController:vc animated:YES];
}
- (IBAction)huxiclick:(id)sender {
    BodyHeatController *vc = nil;
    vc = [[BodyHeatController alloc] initWithNibName:@"BodyHeatController" bundle:nil];
    vc.type=@"呼吸";
    [self.navigationController pushViewController:vc animated:YES];
}
- (IBAction)xueyaclick:(id)sender {
    BodyHeatController *vc = nil;
    vc = [[BodyHeatController alloc] initWithNibName:@"BodyHeatController" bundle:nil];
    vc.type=@"血压";
    [self.navigationController pushViewController:vc animated:YES];
}

-(IBAction)JqClick:(UIButton *)sender{
    
    [self Hidden];
    if (!_pickerview) {
        
        [self Arrangement:@"1"];
        // 建立 UIToolbar
        _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 53+50-self.tpScroll.contentOffset.y, 320, 44)];
        // 選取日期完成鈕 並給他一個 selector
        UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(jqPicker)];
        UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
        // 把按鈕加進 UIToolbar
        //154,238,225
        right.tintColor=[UIColor redColor];
        _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
        [_toolbar setItems:@[Flex,right] animated:YES];
        _pickerview = [[UIPickerView alloc] init];
        _pickerview.delegate =self;
        _pickerview.frame = CGRectMake(0, 53+50+44-self.tpScroll.contentOffset.y, 320, 200);
        NSArray *dataArray = [[NSArray alloc]initWithObjects:@"立春",@"立春后",@"雨水",@"雨水后",@"惊蛰",@"惊蛰后",
                              @"春分",@"春分后",@"清明",@"清明后",@"谷雨",@"谷雨后",@"立夏",@"立夏后",@"小满",@"小满后",
                              @"芒种",@"芒种后",@"夏至",@"夏至后",@"小暑",@"小暑后",@"大暑",@"大暑后",@"立秋",@"立秋后",
                              @"处暑",@"处暑后",@"白露",@"白露后",@"秋分",@"秋分后",@"寒露",@"寒露后",@"霜降",@"霜降后",
                              @"立冬",@"立冬后",@"小雪",@"小雪后",@"大雪",@"大雪后",@"冬至",@"冬至后",@"小寒",@"小寒后",
                              @"大寒",@"大寒后",
                              nil];
        
        pickerData=dataArray;
        
        //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
        [self.view addSubview:_toolbar];
        [self.view addSubview:_pickerview];
        // [self.view addSubview:lbl];
        self.lbljq.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        _datePicker.backgroundColor = [UIColor whiteColor];
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
}


-(IBAction)SsClick:(UIButton *)sender{
    [self Hidden];
    
    
    if (!_pickerview) {
        
        [self Arrangement:@"2"];
        
        //[self setOffset];
        // 建立 UIToolbar
        _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0,237+50-self.tpScroll.contentOffset.y, 320, 44)];
        // 選取日期完成鈕 並給他一個 selector
        UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(ssPicker)];
        UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
        _textfield = [[UITextField alloc] initWithFrame:CGRectMake(20, 5, 100, 30)];
        _textfield.backgroundColor = [UIColor whiteColor];
        _textfield.font=[UIFont systemFontOfSize:13];
        _textfield.delegate=self;
        
        UIBarButtonItem *firstTextField=[[UIBarButtonItem alloc] initWithCustomView:_textfield];
        
        // 把按鈕加進 UIToolbar
        //154,238,225
        right.tintColor=[UIColor redColor];
        _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
        [_toolbar setItems:@[firstTextField,Flex,right] animated:YES];
        _pickerview = [[UIPickerView alloc] init];
        _pickerview.delegate =self;
        _pickerview.frame = CGRectMake(0, 237+50+44-self.tpScroll.contentOffset.y, 320, 180);
        NSArray *dataArray = [[NSArray alloc]initWithObjects:@"舌淡白",@"舌淡",@"舌红",@"舌紫",@"舌红绛",@"舌齿痕",
                              @"舌边起刺",@"舌尖红",
                              nil];
        
        
        pickerData=dataArray;
        
        //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
        [self.view addSubview:_toolbar];
        [self.view addSubview:_pickerview];
        // [self.view addSubview:lbl];
        self.lblss.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        _datePicker.backgroundColor = [UIColor whiteColor];
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
    
}


-(IBAction)WdClick:(UIButton *)sender{
    [self Hidden];
    if (!_pickerview) {
        
      
        if([self.Twdlx isEqualToString:@"西医"])
        {
            [self Arrangementxy:@"3"];
              _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 424-187+50-self.tpScroll.contentOffset.y, 320, 44)];
            // 選取日期完成鈕 並給他一個 selector
            UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(wdPicker)];
            UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
            // 把按鈕加進 UIToolbar
            //154,238,225
            right.tintColor=[UIColor redColor];
            _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
            [_toolbar setItems:@[Flex,right] animated:YES];
            _pickerview = [[UIPickerView alloc] init];
            _pickerview.delegate =self;
            _pickerview.frame = CGRectMake(0, 424-187+50+44-self.tpScroll.contentOffset.y, 320, 180);
            NSArray *dataArray = [[NSArray alloc]initWithObjects:@"口腔温度",@"腋下温度",@"直肠温度",
                                  nil];
            
            pickerData=dataArray;
            
            //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
            [self.view addSubview:_toolbar];
            [self.view addSubview:_pickerview];
            // [self.view addSubview:lbl];
            self.lblwd.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
            _datePicker.backgroundColor = [UIColor whiteColor];

            
            
           
            
        }
        else
        {
            [self Arrangement:@"3"];
            [self setOffset];
              _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 424+50-self.tpScroll.contentOffset.y, 320, 44)];
            // 選取日期完成鈕 並給他一個 selector
            UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(wdPicker)];
            UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
            // 把按鈕加進 UIToolbar
            //154,238,225
            right.tintColor=[UIColor redColor];
            _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
            [_toolbar setItems:@[Flex,right] animated:YES];
            _pickerview = [[UIPickerView alloc] init];
            _pickerview.delegate =self;
            _pickerview.frame = CGRectMake(0, 424+50+44-self.tpScroll.contentOffset.y, 320, 180);
            NSArray *dataArray = [[NSArray alloc]initWithObjects:@"口腔温度",@"腋下温度",@"直肠温度",
                                  nil];
            
            
            pickerData=dataArray;
            
           // UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
            [self.view addSubview:_toolbar];
            [self.view addSubview:_pickerview];
            // [self.view addSubview:lbl];
            self.lblwd.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
            _datePicker.backgroundColor = [UIColor whiteColor];

            
          
            
        }

        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
    
}

-(IBAction)SstsClick:(UIButton *)sender{
    [self Hidden];
    if (!_pickerview) {
        
        if([self.Twdlx isEqualToString:@"西医"])
        {
            [self Arrangementxy:@"3"];
            _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 424-187+50-self.tpScroll.contentOffset.y, 320, 44)];
            // 選取日期完成鈕 並給他一個 selector
            UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(sstsPicker)];
            UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
            // 把按鈕加進 UIToolbar
            //154,238,225
            right.tintColor=[UIColor redColor];
            _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
            [_toolbar setItems:@[Flex,right] animated:YES];
            _pickerview = [[UIPickerView alloc] init];
            _pickerview.delegate =self;
            _pickerview.frame = CGRectMake(0, 424-187+50+44-self.tpScroll.contentOffset.y, 320, 180);
            
            // NSArray *dataArray = [[NSArray alloc]initWithObjects:@"口腔温度",@"腋下温度",@"直肠温度",nil];
            
            NSMutableArray *dataArray =[[NSMutableArray alloc]init];
            for(int i=1;i<15; i++)
            {
                NSString* day = [NSString stringWithFormat:@"II手术%d天",i];
                [dataArray addObject:day];
            }
            
            
            pickerData=dataArray;
            
            //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
            [self.view addSubview:_toolbar];
            [self.view addSubview:_pickerview];
            // [self.view addSubview:lbl];
            self.lblssts.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
            _datePicker.backgroundColor = [UIColor whiteColor];

            
            
        }
        else
        {
            [self Arrangement:@"3"];
            [self setOffset];
            _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 424+50-self.tpScroll.contentOffset.y, 320, 44)];
            // 選取日期完成鈕 並給他一個 selector
            UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(sstsPicker)];
            UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
            // 把按鈕加進 UIToolbar
            //154,238,225
            right.tintColor=[UIColor redColor];
            _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
            [_toolbar setItems:@[Flex,right] animated:YES];
            _pickerview = [[UIPickerView alloc] init];
            _pickerview.delegate =self;
            _pickerview.frame = CGRectMake(0, 424+50+44-self.tpScroll.contentOffset.y, 320, 180);
            
            // NSArray *dataArray = [[NSArray alloc]initWithObjects:@"口腔温度",@"腋下温度",@"直肠温度",nil];
            
            NSMutableArray *dataArray =[[NSMutableArray alloc]init];
            for(int i=1;i<15; i++)
            {
                NSString* day = [NSString stringWithFormat:@"II手术%d天",i];
                [dataArray addObject:day];
            }
            
            
            pickerData=dataArray;
            
            //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
            [self.view addSubview:_toolbar];
            [self.view addSubview:_pickerview];
            // [self.view addSubview:lbl];
            self.lblssts.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
            _datePicker.backgroundColor = [UIColor whiteColor];

            
        }
    
        
        // 建立 UIToolbar
        
        
        
        
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
    
}

-(IBAction)SststClick:(UIButton *)sender{
    [self Hidden];
    if (!_pickerview) {
        
        
        if([self.Twdlx isEqualToString:@"西医"])
        {
            [self Arrangementxy:@"3"];
            _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 424-187+50-self.tpScroll.contentOffset.y, 320, 44)];
            // 選取日期完成鈕 並給他一個 selector
            UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(ssttsPicker)];
            UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
            // 把按鈕加進 UIToolbar
            //154,238,225
            right.tintColor=[UIColor redColor];
            _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
            [_toolbar setItems:@[Flex,right] animated:YES];
            _pickerview = [[UIPickerView alloc] init];
            _pickerview.delegate =self;
            _pickerview.frame = CGRectMake(0, 424-187+50+44-self.tpScroll.contentOffset.y, 320, 180);
            
            // NSArray *dataArray = [[NSArray alloc]initWithObjects:@"口腔温度",@"腋下温度",@"直肠温度",nil];
            
            NSMutableArray *dataArray =[[NSMutableArray alloc]init];
            for(int i=1;i<15; i++)
            {
                NSString* day = [NSString stringWithFormat:@"I手术%d天",i];
                [dataArray addObject:day];
            }
            
            
            pickerData=dataArray;
            
            //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
            [self.view addSubview:_toolbar];
            [self.view addSubview:_pickerview];
            // [self.view addSubview:lbl];
            self.lblsstts.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
            _datePicker.backgroundColor = [UIColor whiteColor];
            
            
        }
        else
        {
            [self Arrangement:@"3"];
             [self setOffset];
            _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 424+50-self.tpScroll.contentOffset.y, 320, 44)];
            // 選取日期完成鈕 並給他一個 selector
            UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(ssttsPicker)];
            UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
            // 把按鈕加進 UIToolbar
            //154,238,225
            right.tintColor=[UIColor redColor];
            _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
            [_toolbar setItems:@[Flex,right] animated:YES];
            _pickerview = [[UIPickerView alloc] init];
            _pickerview.delegate =self;
            _pickerview.frame = CGRectMake(0, 424+50+44-self.tpScroll.contentOffset.y, 320, 180);
            
            // NSArray *dataArray = [[NSArray alloc]initWithObjects:@"口腔温度",@"腋下温度",@"直肠温度",nil];
            
            NSMutableArray *dataArray =[[NSMutableArray alloc]init];
            for(int i=1;i<15; i++)
            {
                NSString* day = [NSString stringWithFormat:@"I手术%d天",i];
                [dataArray addObject:day];
            }
            
            
            pickerData=dataArray;
            
            //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
            [self.view addSubview:_toolbar];
            [self.view addSubview:_pickerview];
            // [self.view addSubview:lbl];
            self.lblsstts.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
            _datePicker.backgroundColor = [UIColor whiteColor];
            
        }

        // 建立 UIToolbar
        
      
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
    
}


-(IBAction)TsClick:(UIButton *)sender{
    [self Hidden];
    if (!_pickerview) {
        
        [self Arrangement:@"2"];
        // 建立 UIToolbar
        _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 237+50-self.tpScroll.contentOffset.y, 320, 44)];
        // 選取日期完成鈕 並給他一個 selector
        UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(tsPicker)];
        //right.tintColor=[UIColor colorWithRed:154/255.0 green:238/255.0 blue:225/255.0 alpha:1];
        UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
        // 把按鈕加進 UIToolbar
        //154,238,225
        _textfield = [[UITextField alloc] initWithFrame:CGRectMake(20, 5, 100, 30)];
        _textfield.backgroundColor = [UIColor whiteColor];
        _textfield.font=[UIFont systemFontOfSize:13];
        _textfield.delegate=self;
        
        UIBarButtonItem *firstTextField=[[UIBarButtonItem alloc] initWithCustomView:_textfield];
        
        right.tintColor=[UIColor redColor];
        _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
        [_toolbar setItems:@[firstTextField, Flex,right] animated:YES];
        _pickerview = [[UIPickerView alloc] init];
        _pickerview.delegate =self;
        _pickerview.frame = CGRectMake(0, 237+50+44-self.tpScroll.contentOffset.y, 320, 180);
        NSArray *dataArray = [[NSArray alloc]initWithObjects:@"苔薄白",@"苔白腻",@"苔黄腻",@"黑苔",@"苔光泽",@"中剥",
                              nil];
        
        
        pickerData=dataArray;
        
        //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
        [self.view addSubview:_toolbar];
        [self.view addSubview:_pickerview];
        // [self.view addSubview:lbl];
        self.lblts.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        _datePicker.backgroundColor = [UIColor whiteColor];
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
}


-(IBAction)MxClick:(UIButton *)sender{
    
    
    [self Hidden];
    if (!_pickerview) {
        
        [self Arrangement:@"2"];
        // 建立 UIToolbar
        _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 237+50-self.tpScroll.contentOffset.y, 320, 44)];
        // 選取日期完成鈕 並給他一個 selector
        UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(mxPicker)];
        UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
        // 把按鈕加進 UIToolbar
        //154,238,225
        right.tintColor=[UIColor redColor];
        _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
        [_toolbar setItems:@[Flex,right] animated:YES];
        _pickerview = [[UIPickerView alloc] init];
        _pickerview.delegate =self;
        _pickerview.frame = CGRectMake(0, 237+50+44-self.tpScroll.contentOffset.y, 320, 180);
        NSArray *dataArray = [[NSArray alloc]initWithObjects:@"浮",@"沉",@"迟",@"数",@"虚",@"实",
                              @"滑",@"洪",@"细",@"弦",@"促",@"结",@"代",
                              nil];
        
        pickerData=dataArray;
        
        //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
        [self.view addSubview:_toolbar];
        [self.view addSubview:_pickerview];
        // [self.view addSubview:lbl];
        self.lblmx.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        _datePicker.backgroundColor = [UIColor whiteColor];
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
}

-(IBAction)timeClick:(UIButton *)sender{
    
    
    [self Hidden];
    
    if (!_pickerview) {
        if([self.Twdlx isEqualToString:@"西医"])
        {
        [self Arrangementxy:@"1"];
        }
        else
        {
         [self Arrangement:@"1"];
        
        }
        // 建立 UIToolbar
        _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 53+50-self.tpScroll.contentOffset.y, 320, 44)];
        // 選取日期完成鈕 並給他一個 selector
        UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(timePicker)];
        UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
        // 把按鈕加進 UIToolbar
        //154,238,225
        right.tintColor=[UIColor redColor];
        _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
        [_toolbar setItems:@[Flex,right] animated:YES];
        _pickerview = [[UIPickerView alloc] init];
        _pickerview.delegate =self;
        _pickerview.frame = CGRectMake(0, 53+50+44-self.tpScroll.contentOffset.y, 320, 180);
        NSArray *dataArray = [[NSArray alloc]initWithObjects:@"02:00",@"06:00",@"10:00",@"14:00",@"18:00",@"22:00",
                              nil];
        
        pickerData=dataArray;
        
        //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
        [self.view addSubview:_toolbar];
        [self.view addSubview:_pickerview];
        // [self.view addSubview:lbl];
        self.lblTime.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        _datePicker.backgroundColor = [UIColor whiteColor];
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
    
    
    //    [self.Texttw resignFirstResponder];
    //    [self.Texttz resignFirstResponder];
    //    [self.Textmb resignFirstResponder];
    //    [self.Textnzl resignFirstResponder];
    //    [self.Textqtc resignFirstResponder];
    //    [self.Textsg resignFirstResponder];
    //    [self.Textxl resignFirstResponder];
    //    [self.Textdb resignFirstResponder];
    //    [self.Texthx resignFirstResponder];
    //    [self.Texthxd resignFirstResponder];
    //    [self.Texthxg resignFirstResponder];
    //
    //
    //    //判断是否打开的
    //    if (_pickerview)
    //    {
    //        [self Arrangement:@"0"];
    //        [_pickerview removeFromSuperview];
    //        [_toolbar removeFromSuperview];
    //        _pickerview = nil;
    //
    //    }
    //
    //    if (!_timePicker) {
    //        [self Arrangement:@"1"];
    //        // 建立 UIToolbar
    //        _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 105+44-self.tpScroll.contentOffset.y, 320, 44)];
    //        // 選取日期完成鈕 並給他一個 selector
    //        UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(timePicker)];
    //        UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    //        // 把按鈕加進 UIToolbar
    //        //154,238,225
    //        right.tintColor=[UIColor redColor];
    //        _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
    //        [_toolbar setItems:@[Flex,right] animated:YES];
    //
    //        _timePicker = [[UIDatePicker alloc] init];
    //        _timePicker.datePickerMode = UIDatePickerModeTime;
    //        _timePicker.frame = CGRectMake(0, 105+44+44-self.tpScroll.contentOffset.y, 320, 200);
    //
    //        [self.view addSubview:_toolbar];
    //        [self.view addSubview:_timePicker];
    //        self.lblTime.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
    //        _timePicker.backgroundColor = [UIColor whiteColor];
    //        //锁定主界面不允许滑动。
    //        self.tpScroll.scrollEnabled=false;
    //    }
}

-(IBAction)dateClick:(UIButton *)sender{
    
    
    [self.Texttw resignFirstResponder];
    [self.Texttz resignFirstResponder];
    [self.Textmb resignFirstResponder];
    [self.Textnzl resignFirstResponder];
    [self.Textqtc resignFirstResponder];
    [self.Textsg resignFirstResponder];
    [self.Textxl resignFirstResponder];
    [self.Textdb resignFirstResponder];
    [self.Texthx resignFirstResponder];
    [self.Texthxd resignFirstResponder];
    [self.Texthxg resignFirstResponder];
    
    
    //判断是否打开的
    if (_pickerview)
    {
        [self Arrangement:@"0"];
        [_pickerview removeFromSuperview];
        [_toolbar removeFromSuperview];
        _pickerview = nil;
        
    }
    
    
    if (!_datePicker) {
        
        
        if([self.Twdlx isEqualToString:@"西医"])
        {
            [self Arrangementxy:@"1"];
        }
        else
        {
            [self Arrangement:@"1"];
            
        }
        // 建立 UIToolbar
        _toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 53+50-self.tpScroll.contentOffset.y, 320, 44)];
        // 選取日期完成鈕 並給他一個 selector
        UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonSystemItemDone target:self action:@selector(datePicker)];
        UIBarButtonItem *Flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
        // 把按鈕加進 UIToolbar
        //154,238,225
        right.tintColor=[UIColor redColor];
        _toolbar.backgroundColor=[UIColor colorWithRed:180/255.0 green:190/255.0 blue:191/255.0 alpha:1];
        [_toolbar setItems:@[Flex,right] animated:YES];
        _datePicker = [[UIDatePicker alloc] init];
        _datePicker.datePickerMode = UIDatePickerModeDate;
        _datePicker.frame = CGRectMake(0, 53+50+44-self.tpScroll.contentOffset.y, 320, 200);
        //UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0,85+88+201,320,1)];
        [self.view addSubview:_toolbar];
        [self.view addSubview:_datePicker];
        // [self.view addSubview:lbl];
        self.lblDate.textColor=[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1];
        _datePicker.backgroundColor = [UIColor whiteColor];
        
        //锁定主界面不允许滑动。
        self.tpScroll.scrollEnabled=false;
        
        
    }
}
-(void) datePicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    
    if([self.Twdlx isEqualToString:@"中医"])
    {
    [self Arrangement:@"0"];
    }
    else
    {
     [self Arrangementxy:@"0"];
    
    }
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    self.lblDate.text = [NSString stringWithFormat:@"%@",[formatter stringFromDate:_datePicker.date]];
    self.lblDate.textColor=[UIColor darkTextColor];
    
    
    
    
    NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];
    
    [dateformatter setDateFormat:@"YYYYMMdd"];
    
    NSString *  strdate=[dateformatter stringFromDate:_datePicker.date];
    
    
    if([self.Twdlx isEqualToString:@"中医"])
    {
        [self setJq:strdate];
    }
    [_datePicker removeFromSuperview];
    [_toolbar removeFromSuperview];
    _datePicker = nil;
    self.tpScroll.scrollEnabled=YES;
    
}

-(void) timePicker {
    if([self.Twdlx isEqualToString:@"中医"])
    {
        [self Arrangement:@"0"];
    }
    else
    {
        [self Arrangementxy:@"0"];
        
    }
    
    NSInteger row =[_pickerview selectedRowInComponent:0];
    NSString *selected = [pickerData objectAtIndex:row];
    self.lblTime.text=selected;
    
    self.lblTime.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}

-(void) sstsPicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    
    if([self.Twdlx isEqualToString:@"西医"])
    {
        [self Arrangementxy:@"0"];
        
        
    }
    else
    {
        [self Arrangement:@"0"];
        
    }

    
    NSInteger row =[_pickerview selectedRowInComponent:0];
    NSString *selected = [pickerData objectAtIndex:row];
    self.lblssts.text=selected;
    
    self.lblssts.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}

-(void) ssttsPicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    
    if([self.Twdlx isEqualToString:@"西医"])
    {
        [self Arrangementxy:@"0"];
        
        
    }
    else
    {
        [self Arrangement:@"0"];
        
    }

    
    NSInteger row =[_pickerview selectedRowInComponent:0];
    NSString *selected = [pickerData objectAtIndex:row];
    self.lblsstts.text=selected;
    
    self.lblsstts.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}

-(void) wdPicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    
    if([self.Twdlx isEqualToString:@"西医"])
    {
        [self Arrangementxy:@"0"];
        
        
    }
    else
    {
        [self Arrangement:@"0"];
        
    }

    NSInteger row =[_pickerview selectedRowInComponent:0];
    NSString *selected = [pickerData objectAtIndex:row];
    self.lblwd.text=selected;
    self.lblwd.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}
-(void) ssPicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    [self Arrangement:@"0"];
    if ([_textfield.text isEqualToString:@""])
    {
        NSInteger row =[_pickerview selectedRowInComponent:0];
        NSString *selected = [pickerData objectAtIndex:row];
        self.lblss.text=selected;
        
    }
    else{
        self.lblss.text=_textfield.text;
    }
    self.lblss.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}

-(void) tsPicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    [self Arrangement:@"0"];
    if ([_textfield.text isEqualToString:@""])
    {
        NSInteger row =[_pickerview selectedRowInComponent:0];
        NSString *selected = [pickerData objectAtIndex:row];
        self.lblts.text=selected;
        
    }
    else{
        self.lblts.text=_textfield.text;
    }
    self.lblts.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}


-(void) mxPicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    [self Arrangement:@"0"];
    NSInteger row =[_pickerview selectedRowInComponent:0];
    NSString *selected = [pickerData objectAtIndex:row];
    self.lblmx.text=selected;
    self.lblmx.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}


-(void) jqPicker {
    // 以下幾行是測試用 可以依照自己的需求增減屬性
    [self Arrangement:@"0"];
    NSInteger row =[_pickerview selectedRowInComponent:0];
    NSString *selected = [pickerData objectAtIndex:row];
    self.lbljq.text=selected;
    self.lbljq.textColor=[UIColor darkTextColor];
    [_pickerview removeFromSuperview];
    [_toolbar removeFromSuperview];
    _pickerview = nil;
    self.tpScroll.scrollEnabled=YES;
}

//返回显示的列数
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}
//返回当前列显示的行数
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return [pickerData count];
}
//返回当前行的内容,此处是将数组中数值添加到滚动的那个显示栏上
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [pickerData objectAtIndex:row];
}
//调整pickerview高度

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component

{
    
    return 30.0;
    
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_textfield resignFirstResponder];
    return YES;
}


- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger) row
       inComponent:(NSInteger)component {
    _textfield.text= [pickerData objectAtIndex:row];
}

@end
